﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.IO;
using System.Linq;
using ChatData;
//using ClientServerChat;

namespace WCFServiceWebRole1
{
    /// <summary>
    /// Stores Direct Messages Client Side
    /// </summary>
    public class DMStore : TimeStream<DMPost>
    {
        public DMStore() { }
        public DMStore(List<DMPost> newdata)
        {
            foreach (DMPost item in newdata)
            {
                this.Add(item);
            }
        }
        public Post getByUser(String user)
        {
            var theitem = from DMPost item in this
                          where item.User == user
                          select item;
            return (DMPost)theitem;
        }
        public DMStore getUserStream(String user)
        {
            var theitem = from DMPost item in this
                          where item.User == user
                          select item;
            return (DMStore)theitem;
        }
        public DMStore getUserStreamSince (String user, DateTime time)
        {
            var theitem = from DMPost  item in this
                          where item.User == user
                          where item.Time >time
                          select item;
            return new DMStore(theitem.ToList<DMPost>());
        }
    }
}
